#include "runtime.h"

RunTime::RunTime(int id, StateMachine* sm)
{
	this->m_id = id;
	this->m_statemachine = sm;
}

RunTime::~RunTime(void)
{
}

STATE RunTime::GetCurState()
{
	return m_statemachine->GetCurState();
}

void RunTime::InvokeService(int id)
{
	if(ServiceManager::GetInstance()->GetServiceByID(id))
	{	
		ServiceManager::GetInstance()->GetServiceByID(id)->Execute();
	}
	else
	{
		cout << "Invoke service failed!!" << endl;
	}
}

void RunTime::InvokeService(int id, Arg* arg)
{
	if(ServiceManager::GetInstance()->GetServiceByID(id))
	{	
		ServiceManager::GetInstance()->GetServiceByID(id)->Execute(arg);
	}
	else
	{
		cout << "Invoke service failed!!" << endl;
	}
}

void RunTime::SetState(const STATE state)
{
	m_statemachine->SetState(state);
}

STATE_TRANS* RunTime::GetStateTrans()
{
	return m_statemachine->GetStateTrans();
}